#!/bin/bash

# 游戏启动脚本
# 用于在容器内启动Windows游戏

GAME_PATH="$1"
DISPLAY=${DISPLAY:-:99}

if [ -z "$GAME_PATH" ]; then
    echo "用法: $0 <游戏路径>"
    echo "示例: $0 /app/games/mygame/game.exe"
    exit 1
fi

if [ ! -f "$GAME_PATH" ]; then
    echo "错误: 游戏文件不存在: $GAME_PATH"
    exit 1
fi

echo "启动游戏: $GAME_PATH"
echo "显示器: $DISPLAY"

# 设置Wine环境
export WINEPREFIX=/app/.wine
export WINEARCH=win32

# 确保Wine环境已初始化
if [ ! -d "$WINEPREFIX" ]; then
    echo "初始化Wine环境..."
    wineboot --init
fi

# 启动游戏
echo "正在启动游戏..."
wine "$GAME_PATH" 